package com.yxw.live_vod_boot.utils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
import java.util.HashMap;
import lombok.Getter;
/**
 * @author jiaxu.huang
 */

@Getter
@ApiModel(value="RedisPipeAccessObject", description="Redis命名管道操作对象")
public class RedisPipeAccessObject <T> implements Serializable {
    private static final long serialVersionUID = -943442677L;
    /**
     * rediskey
     */
    @ApiModelProperty(value = "Redis key")
    private String redisKey; 
    /**
     * 内部mapkey
     */
    @ApiModelProperty(value = "内部mapkey")
    private String redisInnerHashMapKey;   
    /**
     * 需要添加的数据
     */
    @ApiModelProperty(value = "需要添加的数据")
    private T redisValue;
    /**
     * 数据类型：0 普通值类型，1 hash类型
     */
    @ApiModelProperty(value = "添加数据的类型：0 普通值类型，1 hash类型")
    private Integer redisValueType;
    /**
     * 操作类型：0 put，1 delete,2只设置超时时间
     */
    @ApiModelProperty(value = "操作类型：0 put，1 delete,2 只设置超时时间")
    private Integer operationType; 
    /**
     * 超时时间(秒)
     */
    @ApiModelProperty(value = "超时时间(秒)，小于0的为不超时")
    private long time; 
    /**
     * 获取超时时间(秒)对象
     */    
    public static <T>RedisPipeAccessObject getExpireObject(String redisKeyTmp,long timeTmp)
    {
        RedisPipeAccessObject oRedisPipeAccessObject = new RedisPipeAccessObject();
        oRedisPipeAccessObject.redisKey = redisKeyTmp;
        oRedisPipeAccessObject.operationType = 2;
        oRedisPipeAccessObject.time = timeTmp;
        return oRedisPipeAccessObject;
    } 
    /**
     * 获取删除对象
     */
    public static <T>RedisPipeAccessObject getDelObject(String redisKeyTmp)
    {
        RedisPipeAccessObject oRedisPipeAccessObject = new RedisPipeAccessObject();
        oRedisPipeAccessObject.redisKey = redisKeyTmp;
        oRedisPipeAccessObject.operationType=1;
        return oRedisPipeAccessObject;
    }
    /**
     * 获取Map删除对象
     */
    public static <T>RedisPipeAccessObject getDelMapObject(String redisKeyTmp,String mapKeyTmp)
    {
        RedisPipeAccessObject oRedisPipeAccessObject = new RedisPipeAccessObject();
        oRedisPipeAccessObject.redisKey = redisKeyTmp;
        oRedisPipeAccessObject.redisInnerHashMapKey = mapKeyTmp;
        oRedisPipeAccessObject.operationType=1;
        
        return oRedisPipeAccessObject;   
    }
    public static <T>RedisPipeAccessObject getAddObject(String redisKeyTmp,T dataTmp)
    {
        RedisPipeAccessObject oRedisPipeAccessObject = new RedisPipeAccessObject();
        oRedisPipeAccessObject.redisKey = redisKeyTmp;
        oRedisPipeAccessObject.operationType = 0;
        oRedisPipeAccessObject.redisValue = dataTmp;
        oRedisPipeAccessObject.redisValueType = 0;
        oRedisPipeAccessObject.time = -1;
        return oRedisPipeAccessObject;
    } 
    public static <T>RedisPipeAccessObject getAddObject(String redisKeyTmp,T dataTmp,long timeTmp)
    {
        RedisPipeAccessObject oRedisPipeAccessObject = new RedisPipeAccessObject();
        oRedisPipeAccessObject.redisKey = redisKeyTmp;
        oRedisPipeAccessObject.operationType = 0;
        oRedisPipeAccessObject.redisValue = dataTmp;
        oRedisPipeAccessObject.redisValueType = 0;
        oRedisPipeAccessObject.time = timeTmp;
        return oRedisPipeAccessObject;
    }
    public static <T>RedisPipeAccessObject getAddMapObject(String redisKeyTmp,HashMap<T,T> dataTmp)
    {
        RedisPipeAccessObject oRedisPipeAccessObject = new RedisPipeAccessObject();
        oRedisPipeAccessObject.redisKey = redisKeyTmp;
        oRedisPipeAccessObject.operationType = 0;
        oRedisPipeAccessObject.redisValue = dataTmp;
        oRedisPipeAccessObject.redisValueType = 1;
        oRedisPipeAccessObject.time = -1;
        return oRedisPipeAccessObject;
    } 
    public static <T>RedisPipeAccessObject getAddMapObject(String redisKeyTmp,HashMap<T,T> dataTmp,long timeTmp)
    {
        RedisPipeAccessObject oRedisPipeAccessObject = new RedisPipeAccessObject();
        oRedisPipeAccessObject.redisKey = redisKeyTmp;
        oRedisPipeAccessObject.operationType = 0;
        oRedisPipeAccessObject.redisValue = dataTmp;
        oRedisPipeAccessObject.redisValueType = 1;
        oRedisPipeAccessObject.time = timeTmp;
        return oRedisPipeAccessObject;
    }
    public static <T>RedisPipeAccessObject getAddMapValueObject(String redisKeyTmp,String mapKeyTmp,T dataTmp)
    {
        RedisPipeAccessObject oRedisPipeAccessObject = new RedisPipeAccessObject();
        oRedisPipeAccessObject.redisKey = redisKeyTmp;
        oRedisPipeAccessObject.redisInnerHashMapKey = mapKeyTmp;
        oRedisPipeAccessObject.operationType = 0;
        oRedisPipeAccessObject.redisValue = dataTmp;
        oRedisPipeAccessObject.redisValueType = 1;
        oRedisPipeAccessObject.time = -1;
        return oRedisPipeAccessObject;
    }     
}
